{extend name="$base" /}
{block name="resources"}
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
.total>div { text-align: left;font-size: 12px;width:100%;height: 43px;overflow:hidden;color:#666;font-weight: normal;}
.total>div input { margin: 0 5px 0 0;}
.total label {float:left;text-align: left;font-size: 12px; width:12%;overflow:hidden;color:#666;font-weight: normal;}
.total label input {margin: 0 5px 0 0;}
.total label {width: 7%;}
.coupon-title{display:block;float:left;}
.coupon-block{display:block;float:left;}
.coupon-box{height:auto !important;padding-bottom:40px;}
</style>
{/block}
{block name="main"}
<div class="space-10"></div>
<div class="set-style">
	<h4><span></span>基础设置</h4>
	<dl>
		<dt><span class="required">*</span>等级名称：</dt>
		<dd>
			<input type="text" id="min_level_name" class="input-common" value="{$info.min_level_name}">
			<p class="error">请输入等级名称</p>
			<p class="hint">设置会员等级名称</p>
		</dd>
	</dl>

	<dl>
		<dt><span class="required">*</span>升级条件：</dt>
		<dd class="total">
			<div>
				首次进货满&nbsp;&nbsp;&nbsp;
				<input class="input-common harf" onkeyup="value=value.replace(/[^\d+]/g,'')" type="number" min="0" id="min_rank_point" value="{$info.min_rank_point}" style="margin-bottom: 0px; " placeholder="0"><em class="unit">分</em>
				<span class="hint">设置会员等级所需要的累计银币必须是大于等于0的整数</span>
			</div>
			<p class="error">升级条件各值不能为负数</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>分享同级别：</dt>
		<dd class="total">
			<div>

				<input class="input-common harf" onkeyup="value=value.replace(/[^\d+]/g,'')" type="number" min="0" id="level" value="{$info.level}" style="margin-bottom: 0px; " placeholder="0"><em class="unit">人</em>
				<span class="hint">设置分享同级别人数</span>
			</div>
			<p class="error">升级条件各值不能为负数</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>级别达到：</dt>
		<dd class="total">
			<div>

				<input class="input-common harf" onkeyup="value=value.replace(/[^\d+]/g,'')" type="number" min="0" id="level_id" value="{$info.level_id}" style="margin-bottom: 0px; " placeholder="0"><em class="unit">人</em>
				<span class="hint">设置级别达到ID</span>
			</div>
			<p class="error">升级条件各值不能为负数</p>
		</dd>
	</dl>
	<dl>
		<dt>等级须知：</dt>
		<dd>
			<textarea id="min_desc" class="textarea-common">{$info.min_desc}</textarea>
			<p class="hint">会员等级描述信息</p>
		</dd>
	</dl>
	<h4><span></span>等级权益</h4>
	<dl>
		<dt><span class="required">*</span>折扣率：</dt>
		<dd>
			<input class="input-common harf" type="text" id="min_goods_discount" value="{$info.min_goods_discount}"><em class="unit top">%</em>
			<p class="error">折扣率必须为1-100的正整数</p>
			<p class="hint">折扣率单位为百分比，如输入90，表示该会员等级的用户可以以商品原价的90%购买</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>服务费：</dt>
		<dd>
			<input class="input-common harf" value="{$info.min_service_rate}" type="text"  id="min_service_rate"><em class="unit top">%</em>
			<p class="error">直接分享奖励必须为0-100的正整数</p>
			<p class="hint">直接分享奖励单位为百分比，如输入20，表示该会员等级的用户直接分享奖励为20%</p>
		</dd>
	</dl>

	<dl>
		<dt></dt>
		<dd>
			<button class="btn-common btn-big" onclick="save();">保存</button>
			<button class="btn-common-cancle btn-big" onclick="javascript:history.back(-1);" >返回</button>
		</dd>
	</dl>
</div>
<script>

var flag = false;//防止重复提交
//保存
function save(){
	var min_level_name = $("#min_level_name").val();
	var min_goods_discount = $("#min_goods_discount").val();
	var min_desc = $("#min_desc").val();
	var min_service_rate = $("#min_service_rate").val();
	var min_rank_point = $("#min_rank_point").val();
	var level = $("#level").val();
	var level_id = $("#level_id").val();


	if (min_level_name == '') {
		$("#min_level_name").focus().next().show().css("display","inline-block");
		return false;
	} else {
		$(".error").hide();
	}


	if(flag){
		return false;
	}
	flag = true;
	$.ajax({
		type : "post",
		url : "{:__url('ADMIN_MAIN/member/updateMemberMinLevel')}",
		data : {
			'min_level_id' : "{$info.min_level_id}",
			'min_level_name' : min_level_name,
			'min_goods_discount' : min_goods_discount,
			'min_desc' : min_desc,
			'min_service_rate' : min_service_rate,
			'min_rank_point' : min_rank_point,
			'level' : level,
			'level_id':level_id
		},
		success : function(data) {
			if (data["code"] > 0) {
				showTip(data['message'],'success');
				location.href="{:__url('ADMIN_MAIN/member/memberminlevellist')}";
			}else{
				showTip(data['message'],'error');
				flag = false;
			}

		}
	});
}
</script>
{/block}
